<?php

namespace app\mobile\controller;

use app\common\controller\Frontend;
use think\Db;
use think\Request;

class Qiye extends Frontend
{

    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = '';

    public function index()
    {
		$rs_qiye=Db::name('qiye')->order('weigh desc,createtime desc')->paginate(10);
		$this->assign('rs_qiye',$rs_qiye);
        return $this->view->fetch();
    }
	
	public function detail(Request $request){
		$id=$request->param('id/d',0);
		$rs=Db::name('qiye')->where(['id'=>$id])->order('weigh desc')->find();
		$rs_products=Db::name('product')->where([
			'status'=>2,
			'qiye_id'=>$rs['id']
		])->select();
		
		
		$rs['products']=$rs_products;
		
		if(is_null($rs)){
			$this->error('内容不存在');
		}
		$this->assign('rs',$rs);
		$this->assign('empty','<div class="empty">
						<div>
							<img src="/mobile/img/ico_empty.png" >
							<p>没有查询到对应内容</p>
						</div>
					</div>');
		
		return $this->view->fetch();
	}

}
